/**
 * There are code generation
 */
package com.neusoft.lohas.modules.ivm.service.merchant;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.neusoft.lohas.common.service.BaseService;
import com.neusoft.lohas.modules.ivm.dao.merchant.ReceiptTimeDao;
import com.neusoft.lohas.modules.ivm.dao.merchant.TimeSlotDao;
import com.neusoft.lohas.modules.ivm.entity.merchant.Merchant;
import com.neusoft.lohas.modules.ivm.entity.merchant.ReceiptTime;

/**
 * 收货时间Service
 * @author Jackie.Liu
 * @version 2014-10-28
 */
@Component
@Transactional(readOnly = true)
public class ReceiptTimeService extends BaseService {

	@Autowired
	private ReceiptTimeDao receiptTimeDao;
	
	public ReceiptTime get(String id) {
		return receiptTimeDao.get(id);
	}
	
	@Transactional(readOnly = false)
	public void save(ReceiptTime receiptTime) {
		receiptTimeDao.clear();
		receiptTimeDao.save(receiptTime);
	}
	
	@Transactional(readOnly = false)
	public void delete(String id) {
		receiptTimeDao.deleteById(id);
	}
	
	public ReceiptTime findByMerchantId(String merchantId){
		ReceiptTime bean = receiptTimeDao.findByMerchantId(merchantId);
		if (bean == null) {
			bean = new ReceiptTime();
			bean.setMerchant(new Merchant(merchantId));
		}
		return bean;
	}
	
}
